﻿
/***********************************************/
//当前页面实例
var currentPage;
//控件集合实例
var controlsCollection;
//命名空间
var UserList;

$(document).ready(function () {
    var collection = [
        New(ASPxRFTextBox, ['txtDeptName', ['GroupA'], 'DeptName']),
        New(ASPxRFTextBox, ['txtDeptCode', ['GroupA'], 'DeptCode']),
        New(ASPxRFTextBox, ['txtHelpCode', ['GroupA'], 'HelpCode']),
        New(ASPxRFComboBox, ['cbDeptType', ['GroupA'], {valueField: 'DeptType'}])
    ];
    controlsCollection = New(RapidForm, [collection]); 


    //声明页面信息
    var navigationInfo = { moduleValue: 'Permission', itemValue: 'DeptItem', itemName: '部门明细' };
    currentPage = New(RFTreeListPage, [menuHeader, tlList, ['btnView', 'btnAddSibling', 'btnAddSubordinate', 'btnEdit', 'btnDelete'], null, navigationInfo]);
});
//检索
var doSearch = function () {
    currentPage.toSearch();
    doDisplay("search");
}
//显示列表
var doListAll = function () {
    currentPage.toListAll();
    doDisplay("listall");
}
//双击到明细
var doNodeDblClick = function (s, e) {
    currentPage.toNodeDblClick(s, e);
}
//执行查找
var doSubmittedToSearch = function () {
    $('#hfFilterCondition').val(controlsCollection.getQueryString('GroupA'));
    tlList.PerformCallback();
    doListAll();
}
//重置
var doResetToSearch = function () {
    controlsCollection.reset('GroupA');
}
//查看
var doView = function () {
    currentPage.toView();
}
//编辑
var doEdit = function () {
    currentPage.toEdit();
}
//新增同级
var doAddSibling = function () {
    currentPage.toAddSibling();
}
//新增下级
var doAddSubordinate = function () {
    currentPage.toAddSubordinate();
}
//刷新
var doRefresh = function () {
    $('#hfFilterCondition').val('');
    tlList.PerformCallback();
}
//删除
var doBulkDelete = function () {
    $.messager.confirm('确认提示', '确认删除吗?', function (result) {
        if (result) {
            var keyid = tlList.GetFocusedNodeKey();
            SGDemo.Permission.DeptList.Delete(keyid, function (result) {
                if (result.value) {
                    tlList.PerformCallback();
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除成功！',
                        showType: 'slide'
                    });

                } else {
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除失败！',
                        showType: 'slide'
                    });
                }
            });
        }
    });
}
//导出
var doExport = function () {
    pcExport.Show();
}

//关闭导出
var doCloseToExport = function () {
    pcExport.Hide();
}

//查看
var doView = function () {
    currentPage.toView();
}
//添加快捷方式
var doSetShortcut = function () {
    SGDemo.Permission.DeptList.SaveFastAdd(function (result) {
        if (result.value) {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式成功！',
                showType: 'slide'
            });

        } else {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式失败！',
                showType: 'slide'
            });
        }

    });
}